$(function () {
    $.ajax({
        type: 'get',
        url: '/Examiner/GetExaminerInfoForDownLoadPaper?token=' + _token,
        success: function (res) {
            if (res.code >= 0) {
                $('#txtExamineeName').text(res.payload.examineeName);
                $('#txtExamineeSex').text(res.payload.sex == 1 ? '男' : '女');
                $('#txtExamCardNo').text(res.payload.examineeID);
                $('#txtIdCard').text(res.payload.certificateNo);
                $('.photoImg').attr('src', '/images/' + res.payload.photoResource).error(function () {
                    this.src = '//openexamcdn.open.com.cn/openexam/static/App/images/Login/defaultPhoto.jpg';
                    this.onerror = null;
                });
            } else {
                alert(res.message);
                window.location.href = '/Examinee/Login';
            }
        }
    })
});

function toPaper() {
    //try {
    //    // 如果摄像头不可用,直接跳转承诺书页面
    //    if (navigator.getUserMedia) { // Standard
    //        navigator.getUserMedia({"video": true}, function (stream) {
    //            window.location.href = '/Examinee/FaceCompare?token=' + _token; // 人脸识别页面
    //        }, function () {
    //            window.location.href = '/Examinee/Promise?token=' + _token; // 承诺书页面
    //        });
    //    }
    //} catch (ex) {
    //    window.location.href = '/Examinee/Promise?token=' + _token; // 承诺书页面
    //}

    /*
     * loginMode 登录方式:1准考证号  2准考证号+密码 3准考证号+密码+人脸识别  4准考证号+人脸识别
     * if(CSharpFunction)客户端跳转人脸识别 else浏览器跳承诺书页(浏览器人脸识别需要https,但考试页websocket如果是https报错,所以放弃浏览器人脸识别)
    */
    try {
        if(CSharpFunction && (loginMode == "3" || loginMode == "4") ){// 客户端 或者 登录方式要求人脸识别
            window.location.href = '/Examinee/FaceCompare?token=' + _token; // 人脸识别页面
        }else{
            window.location.href = '/Examinee/Promise?token=' + _token; // 承诺书页面
        }
    }catch (err){
        window.location.href = '/Examinee/Promise?token=' + _token; // 承诺书页面
    }
}

function toLogin() {
    window.location.href = '/Examinee/Login';
}

